package com.cxz.kotlin.baselibs.widget

import android.app.Activity
import android.view.Gravity
import android.view.View
import com.cxz.kotlin.baselibs.R
import com.cxz.kotlin.baselibs.base.MyBaseDialog
import com.cxz.kotlin.baselibs.utils.GlideEngine
import com.huantansheng.easyphotos.EasyPhotos
import com.huantansheng.easyphotos.callback.SelectCallback
import kotlinx.android.synthetic.main.dialog_photo_select.*

class PhotoSelectDialog(context: Activity, callback:SelectCallback) : MyBaseDialog(context) {



    private val activity = context
    private val mCallback = callback

    override fun getContentId(): Int {
        return R.layout.dialog_photo_select
    }



    override fun init() {
        setAnimStyle(R.style.dialog_bottom)
        setDialogGravity(Gravity.BOTTOM)
        tvTakePhoto.setOnClickListener {
            dismiss()
            EasyPhotos.createCamera(activity, false).setFileProviderAuthority("com.jinduplan.planmanager.fileprovider")
                .start(mCallback)
        }

        tvAlbum.setOnClickListener {
            dismiss()
            EasyPhotos.createAlbum(activity, false, false, GlideEngine.getInstance())
                .start(mCallback)
        }
        tvCancel.setOnClickListener {
            dismiss()
        }
    }

    fun setCustomClick(count:Int): PhotoSelectDialog {
        tvAlbum.setOnClickListener {
            EasyPhotos.createAlbum(activity, false,false, GlideEngine.getInstance())
                .setCount(count)
                .start(mCallback)
        }
        return this
    }

}